home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
H515.ZIP
/
CENVID.ZIP
/
PRIMES.BAT
< prev
next >
Wrap
DOS Batch File
|
1993-04-09
|
656b
|
24 lines
@echo off
REM Primes.bat Print out prime numbers until a key is pressed or we run out
REM of memory or overflow
cenvi %0.bat
GOTO CENVI_EXIT
printf("Printing prime numbers until a key pressed (or failure):\n")
for ( Count = 0, Try = 2; !kbhit(); Try++ ) {
// check if this is divisible by any of the primes found so far
for ( i = 0; i < Count; i++ )
if !(Try % Prime[i])
break
if ( i == Count )
// this new prime number was found, and so add to the list and print it
printf("%d\t",Prime[Count++]=Try)
}
// flush the keyboard
while( kbhit() ) getch()
printf("\n")
:CENVI_EXIT